//
//  CJEditFirmMessageController.m
//  Boss
//
//  Created by admin on 2018/9/17.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "CJEditFirmMessageController.h"

@interface CJEditFirmMessageController ()
@property (nonatomic,strong)UITextField *textField;
@end

@implementation CJEditFirmMessageController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}
-(void)setupUI
{
    self.navigationItem.title = self.navTitle;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:(UIBarButtonItemStyleDone) target:self action:@selector(clickCancel)];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"保存" style:(UIBarButtonItemStyleDone) target:self action:@selector(saveAction)];
    
    self.view.backgroundColor = [UIColor hexStringToColor:@"#f7f7f7" alpha:1.0];
    
    self.textField = [[UITextField alloc]init];
    [self.view addSubview:self.textField];
    
    self.textField.frame = CGRectMake(0, self.navHeight, kScreenWidth, 44);
    
    self.textField.placeholder = self.placeHoder;
    
    if (self.textString.length) {
        self.textField.text = self.textString;
    }
    self.textField.backgroundColor = [UIColor whiteColor];
    
    
    
}
-(void)clickCancel
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)saveAction
{
    
    if (self.tag == 1) {
        if (!self.textField.text.length) {
            [self toast:self.placeHoder];
        }
        WEAKSELF
        [WYHttpServer editMyFirmWithBrandName:self.textField.text WithFirmIntroduction:nil WithFirmType:nil WithFirmLogo:nil SucessBlock:^(BOOL success, id response, NSString *errorMessage) {
           
            if (success) {
              //   [weakSelf toast:@"修改成功"];
                [weakSelf.navigationController popViewControllerAnimated:YES];
               
            }else{
                [weakSelf toast:errorMessage];
            }
        }];
        
        
        
        
        
        
        
    }
    
    if (self.tag ==2) {
        if (!self.textField.text.length) {
            [self toast:self.placeHoder];
        }
        WEAKSELF
        [WYHttpServer editMyFirmWithBrandName:nil WithFirmIntroduction:self.textField.text WithFirmType:nil WithFirmLogo:nil SucessBlock:^(BOOL success, id response, NSString *errorMessage) {
            if (success) {
                [weakSelf.navigationController popViewControllerAnimated:YES];
             //   [weakSelf toast:@"修改成功"];
            }else{
                [weakSelf toast:errorMessage];
            }
        }];
        
    }
    
    
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
